package web.servlet;

import domain.Category;
import service.CategoryService;
import service.impl.CategoryServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/category/*")
public class CategoryServlet extends BaseServlet {
    private CategoryService service = new CategoryServiceImpl();

    /**
     * 查询所有
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void findAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.查询所有
        List<Category> list = service.findAll();
        //2.序列化为json
        //直接调用父类的工具方法
        writeValue(list,response);
        System.out.println(list + "--------------------->category/findAll");
    }


    public void find(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
